测试链接：https://leetcode.cn/problems/first-missing-positive/
class Solution {
public:
    int firstMissingPositive(vector<int>& nums) {
        int l = 0, r = nums.size() - 1;
        while (l <= r) {
            if(nums[l] == l + 1) { l++; }
            else if (nums[l] <= l || nums[l] > r + 1 ||
                     nums[l] == nums[nums[l] - 1]) {
                swap(nums, l, r--);
            }
            else {
                swap(nums, l, nums[l] - 1);
            }
        }

        return l + 1;
    }
    void swap(vector<int>& nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }
};